public class Test02 {

    public class ListNode1 {
        int val;
        ListNode1 next;

        ListNode1() {
        }

        ListNode1(int val) {
            this.val = val;
        }

        ListNode1(int val, ListNode1 next) {
            this.val = val;
            this.next = next;
        }
    }
    public ListNode1 swapPairs(ListNode1 head) {
        //除以边界情况
        if (head == null){
            return head;
        }
        if (head.next == null){
            return head;
        }

        ListNode1 curNext = swapPairs(head.next.next);
        ListNode1 cur = head.next;
        head.next = curNext;
        cur.next = head;
        return cur;
    }

    public static void main(String[] args) {

    }
}
